<?php
/*
 * Nguoi tham khao
 */
?>

<legend id='step6' class='title-field title-jobs mt_20'><i class='icon icon-plus-sign mt_5 icon-white'></i> Người tham khảo</legend>
<!-- list qua trinh hoc van -->
<?php if (count($model) > 0 && is_array($model)) { ?>
    <?php foreach ($model as $key => $item) { ?>
        <div class="row-fluid row-quatrinh itemt-<?php echo $hid . '-' . $item->id; ?>">
            <div class='span3 ml10'>
                <b><?php echo $item->hoten; ?></b>

            </div>
            <div class='span4'>
                <span class='truong'>
                    <?php echo ucwords($item->chucvu); ?> -
                    <?php echo $item->congty; ?>
                </span><br />
                <span class='mota'>
                    Điện thoại: <?php echo $item->dienthoai; ?><br />
                    Email: <?php echo $item->email; ?><br />
                    <?php echo $item->moiquanhe == 1 ? 'Công việc' : 'Cá nhân'; ?>
                </span>
            </div>
            <div class='span4 align-right'>
                <a href="#" class='edit-tk' prop="<?php echo $hid . '-' . $item->id; ?>"><i class="icon-pencil"></i> Sửa</a>
                <a href="#" class='delete-tk'prop="<?php echo $hid . '-' . $item->id; ?>" ><i class="icon-trash"></i> Xóa</a>
            </div>
        </div>
    <?php } ?>
    <div class='row-fluid'>
        <div class='span3'>&nbsp;</div>
        <div class='span9'>
            <a href="#" class='add-tk btn btn-info mt_20' prop="<?php echo $hid . '-' . $item->id; ?>"><i class="icon-pencil"></i> Thêm</a>
        </div>
    </div>
<?php } else { ?>
    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'nguoithamkhao-form',
        'type' => 'horizontal',
        'action' => Yii::app()->createUrl('ungvien/tintimviec/') . $hid != '' ? '?id=' . $hid : '',
        'enableClientValidation' => true,
        //'enableAjaxValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
            ));
    ?>
    <div class='info-job'>
        <?php echo $form->textFieldRow($model, 'hoten', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'congty', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'chucvu', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'dienthoai', array('class' => 'span4')); ?>
        <?php echo $form->textFieldRow($model, 'email', array('class' => 'span4')); ?>
        <?php echo $form->radioButtonListInlineRow($model, 'moiquanhe', array('1' => 'Công việc', '2' => 'Cá nhân')); ?>
        <div class='div-row'>
            <label class='mt w150'>&nbsp;</label>
            <p class='nn-row'>
                <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Lưu', 'icon' => 'icon-ok icon-white')); ?>
                <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'reset', 'type' => 'primary', 'label' => 'Bỏ qua', 'icon' => 'icon-remove-sign icon-white', 'htmlOptions' => array('class' => 'close-form'))); ?>
            </p> 
        </div>
    </div>
    <?php $this->endWidget(); ?>
<?php } ?>
<script>
$(document).ready(function(){
    //add
    $("a.add-tk").click(function(e) {
        $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/addnguoithamkhao.html<?php if ($hid != '') { echo '?id=' . $hid . '#step6';}    ?>',{action: 'addnguoithamkhao'},
        function(data){
            bootbox.alert(data);
        });
        e.preventDefault();
    });
    //edit
    $("a.edit-tk").click(function(e) {
        var _prop = $(this).attr('prop');
        $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/editnguoithamkhao?data='+_prop,{action: 'editnguoithamkhao'},
        function(data){
            bootbox.alert(data);
        });
        e.preventDefault();
    });
    //delete
    $("a.delete-tk").click(function(e) {
        var t = $(this)
        bootbox.confirm('Bạn chắc có muốn xóa!!!','Bỏ qua','Xóa',function(result){
            if(result){
                var _prop = t.attr('prop');
                $.post('<?php echo Yii::app()->getBaseUrl(true); ?>/ungvien/tintimviec/delnguoithamkhao?data='+_prop,{action: 'delnguoithamkhao'},
                function(data){
                    bootbox.alert(data);
                    $('.itemt-'+_prop).remove();
                });
            }
        });
        e.preventDefault();
    });
});    
</script>